%*******************************************************************************
%*
%*   Copyright ©2009 Alexandru Marin
%*
%*   This file is part of nwave/pMRI C library.
%*
%*   This project started as an MSc degree project during a
%*   stage at the Paris-Est university, under joint supervision of prof.
%*   Bogdan Ionescu (Image Analysis and Processing Laboratory, "Politehica"
%*   University of Bucharest), Caroline Chaux and Jean-Christophe Pesquet
%*   (Laboratoire d'Informatique, Université Paris-Est, Institut Gaspard Monge).
%*
%*   nwave/pMRI C libray is free software: you can redistribute it and/or modify
%*   it under the terms of the GNU General Public License as published by
%*   the Free Software Foundation, either version 2 of the License, or
%*   (at your option) any later version.
%*
%*   nwave/pMRI C libray is distributed in the hope that it will be useful,
%*   but WITHOUT ANY WARRANTY; without even the implied warranty of
%*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%*   GNU General Public License for more details.
%*
%*   You should have received a copy of the GNU General Public License
%*   along with nwave/pMRI C library. If not, see <http://www.gnu.org/licenses/>
%*
%*******************************************************************************



dwtmode

lena_myimpl = mri_read_matrix('lena512_transf.csv');

lena=rgb2gray(imread('lena.jpg')); 
[C,S] = wavedec2(lena, 2, 'db2');

a1 = appcoef2(C,S,'db2',1);
h1 = detcoef2('h',C,S,1);
v1 = detcoef2('v',C,S,1);
d1 = detcoef2('d',C,S,1);

a2 = appcoef2(C,S,'db2',2);
h2 = detcoef2('h',C,S,2);
v2 = detcoef2('v',C,S,2);
d2 = detcoef2('d',C,S,2);

% 1-level resolution
% lena_matlab = [...
%     a1(1:end-1, 1:end-1),...
%     v1(1:end-1, 1:end-1);...
%     h1(1:end-1, 1:end-1),...
%     d1(1:end-1, 1:end-1)];

% 2-level resolution
lena_matlab = [...
    a2(1:end-2, 1:end-2),...
    v2(1:end-2, 1:end-2);...
    h2(1:end-2, 1:end-2),...
    d2(1:end-2, 1:end-2)];

lena_matlab = [...
    lena_matlab,...
    v1(1:end-1, 1:end-1);...
    h1(1:end-1, 1:end-1),...
    d1(1:end-1, 1:end-1)];


%figure;image(255*lena_matlab/(max(lena_matlab(:))));colormap(gray(256));
%figure;image(255*lena_myimpl/(max(lena_myimpl(:))));colormap(gray(256));


